package com.db;
import java.sql.*;
public class Database {
    static Connection conn = null;


    public  Database() throws ClassNotFoundException, SQLException {

        Class.forName("com.mysql.cj.jdbc.Driver");//注册驱动
        conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/study?serverTimezone=GMT%2B8", "root", "1234");
    }
    public void showConnection() {
        if (conn == null) {
            System.out.println("数据库连接失败");
        } else {
//            System.out.println(conn);
            System.out.println("数据库连接成功");
        }
    }
}
